package cn.sdc.bugKiller.web;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import cn.sdc.bugKiller.service.ContextService;
import cn.sdc.bugKiller.util.DbUtil;

public class InitServlet extends HttpServlet {

	@Override
	public void init(ServletConfig config) throws ServletException {
		ServletContext sc = config.getServletContext();
		DbUtil.setJdbcFilePath(sc.getRealPath("/WEB-INF/classes/jdbc.properties"));
		ContextService.setServletContext(sc);
		ContextService.setResourceRootPath();
	}
	
	@Override
	public void destroy() {
		DbUtil.getInstance().close();
		ContextService.clearSession();
	}
	
}
